#include "toolbar.h"

ToolBar::ToolBar(const QString &title, QWidget *parent) :
    QToolBar(title, parent)
{
}

void ToolBar::setRole(ToolBar::Role role)
{
    switch(role) {
    case MainToolBar:
        setupMainRole();
        break;
    default:
        break;
    }
}

void ToolBar::setupMainRole()
{
    setMovable(false);
    setToolButtonStyle(Qt::ToolButtonTextBesideIcon);

    ToolBarAction * tmp = NULL;

    tmp = new ToolBarAction(QIcon::fromTheme("document-new"), QString(""), this);
    tmp->setStatusTip("Create a new file");
    addAction(tmp);

    tmp = new ToolBarAction(QIcon::fromTheme("document-open"), QString("Open"), this);
    tmp->setStatusTip("Open an existing file");
    addAction(tmp);

    tmp = new ToolBarAction(QIcon::fromTheme("document-save"), QString("Save"), this);
    tmp->setStatusTip("Save current file");
    addAction(tmp);

    addSeparator();

    tmp = new ToolBarAction(QIcon::fromTheme("edit-undo"), QString("Undo"), this);
    tmp->setStatusTip("Undo previous action");
    addAction(tmp);
}

ToolBarAction::ToolBarAction(const QIcon &icon, const QString &text, QObject *parent) :
    QAction(icon, text, parent)
{
}
